package com.test5;

import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * 文件复制
 */
public class FileCopy {
    public static void main(String[] args) throws Exception {
        //文件字节输入流，被复制的文件
        FileInputStream fis = new FileInputStream("C:\\Users\\LDH\\Desktop\\test.txt");
        //文件字节输出流，复制后的文件
        FileOutputStream fos = new FileOutputStream("C:\\Users\\LDH\\Desktop\\test2.txt");
        //一边读，一边写
        byte[] buf = new byte[1024];
        int count = 0;
        while ((count = fis.read(buf)) != -1){
            fos.write(buf,0,count);
        }
        //关闭
        fis.close();
        fos.close();
    }
}
